<html>
<head>
	<script language="javascript"  src="/java_scripts/jquery/jquery.js"></script>

	
	<script language="javascript"  src="/java_scripts/jqueryFileTree/jqueryFileTree.js"></script>
	<link href="/java_scripts/jqueryFileTree/jqueryFileTree.css" rel="stylesheet" type="text/css" media="screen" />
	<script language="javascript"  src="/java_scripts/jqueryContextMenu/jquery.contextMenu.js"></script>
	<link href="/java_scripts/jqueryContextMenu/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
        <script language="javascript"  src="/java_scripts/base64/base64.js"></script>
        <script language="javascript"  src="/java_scripts/main.js"></script>


</head>
<body>
	<script language="javascript">
		function refreshFTree()
		{	
		        $("#filetreeDiv").fileTree({root: userScriptsFolder, script: jqueryFileTreePyDirListFn, multiFolder: true}, function() {
				
		        });
		}


		$(document).ready ( function() {

		// Loading filetree upfront

			refreshFTree();

			$("#filetreeDiv").contextMenu({
			    menu: 'rightClickMenu'
			}, function(action, el, pos) {
			    if (action == "new") {
				var fileName = prompt("Please enter file name", "");
				var ext = fileName.split(".")[1];

				switch(ext)
				{
					case "py":
							parent.language = "python";
							break;
					case "rb":
							parent.language = "ruby";
							break;
					case "sh":
							parent.language = "bash";
							break;
					case "pl":
							parent.language = "perl";
							break;
					default:
							parent.language = "bash";
							break;
				}
				var filePath = "/" + parent.userScriptsFolder + "/" + fileName;

				parent.fileSelected = filePath;
				parent.createFile(filePath);
				refreshFTree();
			    }
			    if (action == "delete") {
				parent.deleteFile();
				refreshFTree();
			    }
			    if (action == "save") {
				writeToFile();
				refreshFTree();
			    }
			});
		});
	</script>
	<div id="filetreeDiv" style="margin-top:0px; margin-left:0px; width:22%; height:400px; float:left;"></div>
	<ul id="rightClickMenu" class="contextMenu">
	    <li class="new">
		<a href="#new">New</a>
	    </li>
	    <li class="delete">
		<a href="#delete">Delete</a>
	    </li>
	    <li class="save">
		<a href="#save">Save</a>
	    </li>
	</ul>
</body>
</html>

